package com.example.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;

import com.example.dto.SmsCodeResquest;

@Tag(name = "演示接收请求参数", description = "演示如何接收不同类型的请求参数")
@RestController
@RequestMapping("/api/request")
public class RequestController {
    
    // 演示接收JSON请求体参数
    @PostMapping("/body")
    public String getBodyParams(@RequestBody SmsCodeResquest params) {
        return "接收到的请求体参数 - 手机号: " + params.getMobile();
    }

    // 演示接收query参数
    @GetMapping("/query")
    public String getQueryParams(@RequestParam String name, @RequestParam int age) {
        return "接收到的查询参数 - 姓名: " + name + ", 年龄: " + age;
    }

    // 演示接收path参数
    @GetMapping("/path/{id}/{number}")
    public String getPathParams(@PathVariable String id, @PathVariable int number) {
        return "接收到的路径参数 - ID: " + id + ", Number: " + number;
    }
}
